﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerContro : MonoBehaviour {

    public float time = 0;
    public int frameNumber = 15;//1秒执行的总帧率
    public int frameCount = 0;
    private Rigidbody rigidbody;

    void Start () {
        rigidbody = GetComponent<Rigidbody>();
        rigidbody.velocity = new Vector3(2, 0, 0);
	}
	
	// Update is called once per frame
	void Update () {
        //动画效果
        time += Time.deltaTime;
		if(time>=1.0/frameNumber)
        {
            frameCount++;
            time -= 1.0f / frameNumber;
            int index = frameCount % 3;
            GetComponent<Renderer>().material.SetTextureOffset("_MainTex", new Vector2(0.333f * index, 0));
        }
        //点击鼠标运动
        if (Input.GetMouseButton(0))
        {
            Vector3 v3 = rigidbody.velocity;
            rigidbody.velocity = new Vector3(v3.x + 1, 5, v3.z);
        }
	}
}
